package com.cxy.common.request;

import com.fy.baselibrary.retrofit.BaseBean;
import com.fy.baselibrary.utils.Constant;
import com.google.gson.annotations.SerializedName;

/**
 * 网络请求 返回数据 格式化对象
 * Created by fangs on 2017/11/6.
 */
public class BeanModule<T> implements BaseBean<T> {

    /**
     * resultcode : 0
     * response : ""
     * resultmessage : 成功
     */

    @SerializedName(value = "resultcode", alternate = "code")
    private int resultcode;
    @SerializedName(value = "resultmessage", alternate = {"message", "msg", "success"})
    private String resultmessage = "";
    @SerializedName(value = "response", alternate = {"data", "list", "url", "cusData"})
    private T response;


    @Override
    public boolean isSuccess(){
        return resultcode == 200;
    }

    @Override
    public int getCode() {
        return Constant.LAYOUT_CONTENT_ID;
    }

    @Override
    public String getMsg() {
        return resultmessage;
    }

    @Override
    public T getData() {
        return response;
    }

    public int getResultcode() {
        return resultcode;
    }

    public void setResultcode(int resultcode) {
        this.resultcode = resultcode;
    }

    public String getResultmessage() {
        return resultmessage == null ? "" : resultmessage;
    }

    public void setResultmessage(String resultmessage) {
        this.resultmessage = resultmessage;
    }

    public T getResponse() {
        return response;
    }

    public void setResponse(T response) {
        this.response = response;
    }
}
